package com.adnaan.restaurant.mapper;

import com.adnaan.restaurant.entity.ResOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ResOrderMapper {

    @Insert("insert into res_order_list (detail, user_id, total_price, status, create_time, address, shop_id) values (#{detail},#{userId},#{totalPrice},#{status},now(),#{address},#{shopId})")
    int buy(ResOrder resOrder);

    @Select("select o.id, o.detail, o.user_id, o.total_price, o.status, o.create_time, o.address, o.shop_id,o.star,o.evaluate, o.update_time,s.name as shopName from res_order_list o left join res_shop s on o.shop_id = s.id where o.user_id = #{userId}")
    List<ResOrder> getMyOrder(Long userId);
}
